import java.util.regex.Pattern;


public class Car {

	private String registrationNumber;
	private Name driverName;
	
	public Car(String registrationNumber, Name driverName) {
		//car registration number must not be blank and length
		if( registrationNumber.trim().length() ==0)    
        {
	          throw new IllegalStateException(
	             "Cannot have blank car registration number or number"
	             + "seats");
	        }
		if (registrationNumber.matches(",/+-*&^%$£!¬|><?,"))
        	throw new IllegalStateException("No non-letter in "
        		+ "car registration number");
		 
		
		
		this.registrationNumber = registrationNumber;
		this.driverName = driverName;
	}


    public String getRegistrationNumber() {
		return registrationNumber;
	}

	public void setRegistrationNumber(String registrationNumber) {
		this.registrationNumber = registrationNumber;
	}

	public Name getDriverName() {
		return driverName;
	}

	public void setDriverName(Name driverName) {
		this.driverName = driverName;
	}
	
	public boolean equals(Object other) {
		if(other instanceof Car) {
			Car otherCar = (Car) other;
			if(registrationNumber.equals(otherCar.registrationNumber))
			return true;
		}
		return false;	
	}
	
	public int hashCode() {
		return registrationNumber.hashCode();
	}
}
